package chenji.moreitemfunapi.util;

public class BasicTypeUtil {
	public static int turnToInteger(String value) {
		try {
			return Integer.valueOf(value);
		} catch (Exception ex) {
			return -1;
		}
	}

	public static long turnToLong(String value) {
		try {
			return Long.valueOf(value);
		} catch (Exception ex) {
			return -1L;
		}
	}

	public static short turnToShort(String value) {
		try {
			return Short.valueOf(value);
		} catch (Exception ex) {
			return (short) -1;
		}
	}

	public static boolean turnToBoolean(String val) {
		if (val.equalsIgnoreCase("t") || val.equalsIgnoreCase("true")) {
			return true;
		}
		if (val.equalsIgnoreCase("f") || val.equalsIgnoreCase("false")) {
			return false;
		}
		return false;
	}

	public static boolean isBoolean(String val){
		if (val.equalsIgnoreCase("t") || val.equalsIgnoreCase("true")||val.equalsIgnoreCase("f") || val.equalsIgnoreCase("false")) {
			return true;
		}
		return false;
	}
}
